Problem with logic of this pattern problem

visit shbcf.ru